/**
 *    Copyright (C) 2008  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_CORE_MAP_VECTOR_PAGES_HPP
#define	_CUBEFS_CORE_MAP_VECTOR_PAGES_HPP

#include <cubefs/core/btree/pages.hpp>

namespace cubefs    {
namespace core      {
namespace map       {
namespace vector    {

template <typename Key, Int Indexes>
class VectorPageBase {};

}
}
}
}


namespace cubefs    {
namespace core      {
namespace btree     {

using namespace cubefs::core;

#pragma pack(1)

template <typename Key, Int Indexes, typename Base>
class PageComponent<map::vector::VectorPageBase<Key, Indexes>, Base>: public Base {
    Key prefixes_[Indexes];
public:
    PageComponent() : Base() {}

    Key &prefix(Int idx) {
        return (Key&) prefixes_[idx];
    }

    const Key *prefixes() const {
        return prefixes_;
    }

    Key *prefixes() {
        return prefixes_;
    }

    void set_prefixes(const Key *pfx) {
        for (Int c = 0; c < Indexes; c++) {
            prefixes_[c] = pfx[c];
        }
    }

    void BuildFieldsList(MetadataList &list) {
        Base::BuildFieldsList(list);
        list.push_back(new TypedField<Key>(&prefixes(), "PREFIXES", Indexes));
    }
};


#pragma pack()

}
}
}


#endif	/* _CUBEFS_CORE_MAP_VECTOR_PAGES_HPP */